package com.vdong.restful.controller;


import com.vdong.restful.api.request.ShipperOrderUserRequest;
import com.vdong.restful.api.request.ShipperParamRequest;
import com.vdong.restful.api.response.Response;
import com.vdong.restful.service.ShipperApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/shippe")
public class ShipperController {

    @Autowired
    private ShipperApiService shipperApiService;

    /**
     * 查询服务商支持的快递公司
     *
     * @param
     * @return
     */

    @RequestMapping(value = "/getListShipperService.json")
    public Response findAllShipper() {
        return shipperApiService.findByApplicationId(1);

    }

    @RequestMapping(value = "/addOneShipperOrderUserService.json")
    public Response addShipperOrderUser(@Validated(ShipperOrderUserRequest.AddValation.class) @RequestBody ShipperOrderUserRequest shipperOrderUserRequest) {


        return shipperApiService.addShipperOrderUser(shipperOrderUserRequest);

    }

    @RequestMapping(value = "/updateOneShipperOrderUserService.json")
    public Response updateShipperOrderUser(@RequestBody @Validated(ShipperOrderUserRequest.UpdateValation.class) ShipperOrderUserRequest shipperOrderUserRequest) {


        return shipperApiService.saveShipperOrderUser(shipperOrderUserRequest);

    }

    /**
     * 获取单条用户快递公司电子面单账户信息
     *
     * @param shipperParamRequest
     * @return
     */
    @RequestMapping(value = "/getOneShipperOrderUserService.json")
    public Response findOneShipperOrderUser(String key, @RequestBody @Validated(ShipperParamRequest.FindOneShipperOrderUserValidate.class) ShipperParamRequest shipperParamRequest) {

        return shipperApiService.findOneOrderUser(shipperParamRequest.getUserId(), key, shipperParamRequest.getShipperId());

    }

    @RequestMapping(value = "/getListShipperOrderUserService.json")
    public Response findShipperOrderUser(String key, @RequestBody @Validated(ShipperParamRequest.FindShipperOrderUserValidate.class) ShipperParamRequest shipperParamRequest) {

        return shipperApiService.findListOrderUser(shipperParamRequest.getUserId(), key);

    }

    @RequestMapping(value = "/getOneShipperOrderValidataonService.json")
    public Response findShipperOrderUsersValidation(@RequestBody @Validated(ShipperParamRequest.FindShipperOrderValidate.class) ShipperParamRequest shipperParamRequest) {
        return shipperApiService.findOneOrderValidataon(shipperParamRequest.getShipperId());
    }

}
